<?php
ini_set("display_errors", 1);
ini_set('error_reporting', E_ALL ^ E_NOTICE);

define('DOCUMENT_ROOT', realpath(dirname(__FILE__)));
define('APPLICATION_PATH', realpath(DOCUMENT_ROOT.'/../application'));
define('LIBS_PATH', realpath(DOCUMENT_ROOT . '/../library'));
define('DATA_PATH', realpath(DOCUMENT_ROOT.'/../data'));

//Setup Include Paths
set_include_path(implode(PATH_SEPARATOR,array(    
    APPLICATION_PATH,
    LIBS_PATH,
    get_include_path()
)));


//Load bootstrap
define('ENVIRONMENT', 'env');
define('APP_ENV', isset($_SERVER['APPLICATION_ENV'])?$_SERVER['APPLICATION_ENV']:'development');

try
{	    

	//Get options
	$options = array(
	    'bootstrap' => array(
            'path'   => APPLICATION_PATH.'/Bootstrap.php',
            'class'  => 'Bootstrap'
        ),
        'phpSettings' => array(
            'display_startup_errors' => (APP_ENV == 'development')?0:0,
            'display_errors'         => (APP_ENV == 'development')?1:0
        )
	);
	
	//Load Application
    require_once 'Zend/Application.php';
    $application = new Zend_Application(
        APP_ENV,
        $options
    );    
    require_once APPLICATION_PATH . '/configs/defined.php';
    //Display
    $application->bootstrap()->run();    
} 
catch(Exception $exception) 
{
    echo '<html><body><center>'
        .'An exception occured while bootstrapping the application.';
    echo APP_ENV.'<br/>';
    if(APP_ENV == 'development')
    {
        echo '<br /><br />'.$exception->getMessage().'<br />'
        .'<div align="left">Stack Trace:'
        .'<pre>'.$exception->getTraceAsString().'</pre></div>';
    }
    echo '</center></body></html>';
    exit(1);
}

?>